package com.wang.sse.config;

import com.wang.sse.service.SseEmitterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author: wangning1@abupdate.com
 * @date: 2023-12-14 13:50
 **/
// @Configuration
// public class SendMessageTask {
//     @Autowired
//     private SseEmitterService sseEmitterService;
//
//     /**
//      * 定时执行 秒 分 时 日 月 周
//      */
//     @Scheduled(cron = "*/5 * * * * *")  // 间隔5秒
//     public void sendMessageTask() {
//         Message message = new Message();
//         DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//         message.setData(LocalDateTime.now().format(format));
//         sseEmitterService.sendMessage(message);
//     }
// }